﻿using IdentityServer4.Models;
using System.Collections;
using System.Collections.Generic;
using IdentityServer4.Test;
using System;
using IdentityServer4;

namespace MvcCookieAuthSample
{
    public class Config
    {
        public static IEnumerable<ApiResource> GetResource()
        {
            return new List<ApiResource>
            {
                new ApiResource("api1","API Application")
            };
        }

        public static IEnumerable<Client> GetClients()
        {
            return new List<Client>
            {
                new Client(){
                    ClientId="mvc",
                    ClientName="Mvc Client",
                    ClientUri="http://localhost:5001",
                    //LogoUri=
                    AllowRememberConsent=true,

                    AllowedGrantTypes=GrantTypes.Implicit,

                    ClientSecrets={
                        new Secret("secret".Sha256())
                    },
                    RequireConsent=true,
                    RedirectUris={ "http://localhost:5001/signin-oidc"},//生产环境配置到数据库
                    PostLogoutRedirectUris={ "http://localhost:50001/signout-callback-oidc"},
                     AllowedScopes={
                        IdentityServerConstants.StandardScopes.Profile,
                        IdentityServerConstants.StandardScopes.OpenId,
                        IdentityServerConstants.StandardScopes.Email
                    }
                },
                new Client(){
                    ClientId="pwdClient",
                    AllowedGrantTypes=GrantTypes.ResourceOwnerPassword,

                    ClientSecrets={
                        new Secret("secret".Sha256())
                    },
                     AllowedScopes={"api"}
                }
            };
        }

        public static List<TestUser> GetTestUsers() {
            return new List<TestUser>
            {
                new TestUser{
                    SubjectId="10000",
                    Username="shitong",
                    Password="123456"
                }
            };
        }

        public static IEnumerable<IdentityResource> GetIdentityResource()
        {
            return new List<IdentityResource>
            {
                new IdentityResources.OpenId(),
                new IdentityResources.Profile(),
                new IdentityResources.Email()
            };
        }
    }
}
